<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Product;
use App\Models\Category;

class InitProduct extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'InitProduct';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $catalogos = [
            [
                'id' => 1,
                'title' => '家政保洁',

            ], [
                'id' => 2,
                'title' => '家电清洗',
            ], [
                'id' => 3,
                'title' => '家庭消杀',
            ], [
                'id' => 4,
                'title' => '洗衣洗鞋',
            ]

        ];
        foreach($catalogos as $catalogo) {
            Category::firstOrCreate(['title' => $catalogo['title']], $catalogo);
        }

       
/* 
ZX00041 保洁面积
01 0-60平米
02 61-80平米
03 81-100平米
04 101-120平米
05 121-140平米
06 擦玻璃服务（10平米）
07 厨房深度保洁
08 卫生间深度保洁
09 卫生间厨房深度保洁 
*/

/**
 * KQZLLX  空气检查治理类型
 * 
01 含氯药剂消毒灭菌120平米
02 含氯药剂消毒灭菌120-200平米
03 光触媒消毒1月增强型60平米
04 光触媒消毒1月增强型80平米光
05 光触媒消毒1月增强型100平米光
06 光触媒消毒1月增强型120平米光
07 SNAP光触媒消毒1年超强型60平米
08 SNAP光触媒消毒1年超强型80平米
09 SNAP光触媒消毒1年超强型100平米
10 SNAP光触媒消毒1年超强型120平米
11 全屋甲醛检测
12 两室甲醛CMA检测
13 新装房除甲醛60平米
14 新装房除甲醛80平米
15 新装房除甲醛100平米
16 新装房除甲醛120平米
 */ 

        $products = [
            [
                'id' => 1,
                'category_id' => 1,
                'name' => '61-80平米家庭深度保洁服务',
                'cover' => '/images/clear01.jpg',
                'original_price' => 800.00,
                'current_price' => 800.00,
                'summary' => '本商品为虚拟商品，无实物。',
                'description' => '
                    <img src="/images/pm01_01.jpg">
                ',
                'provider' => 'suning',
                'attributes' =>  json_encode([
                    'cmmdtyQaType' => '1', //质保标识 0：保内；1：保外
                    'extdCmmdtyBand' => '000280DXZ',
                    'extdCmmdtyCtgry' => 'R9010411', //苏宁商品编码
                    'extdCommodityName' => '家庭保洁', //苏宁商品名称
                    'proNameDesc' => '清洗保养',
                    'brandCode' => '0DXZ', //苏宁品牌编码
                    'buCode' => '00028',
                    'proName' => '08',
                    'propertyCode' => [
                        'ZX00041' => '02'
                    ]
                ])
            ],
            [
                'id' => 3,
                'category_id' => 2,
                'name' => '燃气热水器清洗1台 高温蒸汽消毒 深层清洁去污',
                'cover' => '/images/clear00.jpg',
                'original_price' => 128.00,
                'current_price' => 128.00,
                'summary' => '本商品为虚拟商品，无实物。',
                'description' => '
                  <img src="/images/pm03_01.jpg">
                ',
                'provider' => 'suning',
                'attributes' =>  json_encode([
                    'cmmdtyQaType' => '1', //质保标识 0：保内；1：保外
                    'extdCmmdtyBand' => '000130DXZ',
                    'extdCmmdtyCtgry' => 'R2301003', //苏宁商品编码
                    'extdCommodityName' => '燃气热水器', //苏宁商品名称
                    'proNameDesc' => '安装,上门维修,拆机,上门设计,清洗保养',
                    'brandCode' => '0DXZ', //苏宁品牌编码
                    'buDesc' => '厨卫',
                    'buCode' => '00013',
                    'proName' => '01,02,03,06,08'

                ])
            ],
            [
                'id' => 2,
                'category_id' => 2,
                'name' => '家用烟灶套餐（油烟机+燃气灶）清洗',
                'cover' => '/images/clear03.jpg',
                'original_price' => 218.00,
                'current_price' => 218.00,
                'summary' => '本商品为虚拟商品，无实物卡。整机半拆卸，高温蒸汽洗，面面俱到，焕然一新！！',
                'description' => '
                    <img src="/images/pm02_01.jpg">
                ',
                'provider' => 'suning',
                'attributes' =>  json_encode([
                    'cmmdtyQaType' => '1', //质保标识 0：保内；1：保外
                    'extdCmmdtyBand' => '000130DXZ',
                    'extdCmmdtyCtgry' => 'R2101001', //苏宁商品编码
                    'extdCommodityName' => '厨电套装', //苏宁商品名称
                    'proNameDesc' => '安装,上门维修,拆机,上门设计,清洗保养',
                    'brandCode' => '0DXZ', //苏宁品牌编码
                    'buCode' => '00013',
                    'buDesc' => '厨卫',
                    'proName' => '01,02,03,06,08',

                ])
            ],
            [
                'id' => 4,
                'category_id' => 3,
                'name' => '家庭雾化消毒灭菌服务121-160平米（含氯消毒剂）',
                'cover' => '/images/clear04.jpg',
                'original_price' => 488.00,
                'current_price' => 488.00,
                'summary' => '环保药剂、雾化全屋无死角、杀菌消杀上门服务',
                'description' => '
                    <img src="/images/pm04_01.jpg">
                    <img src="/images/pm04_02.jpg">
                    <img src="/images/pm04_03.jpg">
                    <img src="/images/pm04_04.jpg">
                    <img src="/images/pm04_05.jpg">
                ',
                'provider' => 'suning',
                'attributes' =>  json_encode([
                    'cmmdtyQaType' => '1', //质保标识 0：保内；1：保外
                    'extdCmmdtyBand' => '000280DXZ',
                    'extdCmmdtyCtgry' => 'R9007124', //苏宁商品编码
                    'extdCommodityName' => '空气检查治理服务', //苏宁商品名称
                    'proNameDesc' => '清洗保养',
                    'brandCode' => '0DXZ', //苏宁品牌编码
                    'proName' => '08',
                    'buCode' => '00028',
                    'buDesc' => '售后事业部',
                    'propertyCode' => [
                        'KQZLLX' => '02'
                    ]
                ])
            ]
        ];
        // $this->info(json_encode($products));
        Product::where('id', '>', 0)->delete();
        foreach($products as $product) {
            Product::Create($product);
        }
        return 0;
    }
}
